package com.dave.common.utils;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.util.StatusPrinter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @PageName com.dave.common.utils
 * @Description 启动加载指定路径的logbcak配置文件
 * @Author 何全裕
 * @Create 2017-07-30 17:48
 * @Version 1.0
 **/
public class LoadLogback {
    private static final Logger logger = LoggerFactory.getLogger(LoadLogback.class);
    static{
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(lc);
        lc.reset();
        try {
            configurator.doConfigure("src/main/resources/logback/logback.xml");
        } catch (JoranException e) {
            e.printStackTrace();
        }
        StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
        System.out.println("===================");
        logger.debug("Hello {}","debug message");
        }
    }
